package com.caiyi.tips.user.mapper;

import com.caiyi.tips.user.bean.UserBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

@Component(value = "userMapper")
public interface UserMapper {
    @Select("select count(*) from tb_user where istate=0 and cphone=#{phone,jdbcType=VARCHAR}")
    int checkUserExistPhone(@Param("phone") String phone);

    @Select("select count(*) from tb_expert where istate=0 and cphone=#{phone,jdbcType=VARCHAR}")
    int checkExpertExistPhone(@Param("phone") String phone);

    @Select("select count(*) from tb_user where istate=0 and cnickid=#{nickid,jdbcType=VARCHAR}")
    int checkUserExistNickid(@Param("nickid") String nickid);

    @Select("select count(*) from tb_expert where istate=0 and cphone=#{nickid,jdbcType=VARCHAR}")
    int checkExpertExistNickid(@Param("nickid") String nickid);

    int saveUser(UserBean userBean);

    int saveExpert(UserBean userBean);

   @Update("update tb_expert  set cpassword = #{password,jdbcType=VARCHAR}  where  cuserid=#{userid,jdbcType=VARCHAR}")
    int updateUserInfo(UserBean userBean);
}
